package com.hznu.ucenter.controller;


import com.hznu.commonutils.R;
import com.hznu.ucenter.entity.Ucenter;
import com.hznu.ucenter.entity.vo.RegisterVo;
import com.hznu.ucenter.service.UcenterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cdd
 * @since 2021-03-10
 */
@RestController
@RequestMapping("/ucenter")
@Api( tags = "用户中心")
public class UcenterController {

    @Autowired
    private UcenterService ucenterService;

    @PostMapping("register")
    @ApiOperation("用户注册")
    public R register(@RequestBody RegisterVo registerVo) {
        ucenterService.insertUser(registerVo);
        return R.ok();
    }

    @PostMapping("login")
    @ApiOperation("用户登录")
    public R login(String phoneOrEmail, String password) {
        Long userId = ucenterService.login(phoneOrEmail,password);
        return R.ok().data("userId",userId);
    }

}

